package com.kevin.designpattern.iterator;

public class Client {
    public static void main(String[] args) {

        // 创建聚合对象
        StudentAggregateImpl aggregate = new StudentAggregateImpl();

        //添加元素
        aggregate.addStudent(new Student("张三", "001"));
        aggregate.addStudent(new Student("李四", "002"));
        aggregate.addStudent(new Student("王五", "003"));
        aggregate.addStudent(new Student("赵六", "004"));
        aggregate.addStudent(new Student("七仔", "005"));

        //遍历
        StudentIterator studentIterator = aggregate.getStudentIterator();
        while (studentIterator.hasNext()) {
            Student next = studentIterator.next();
            System.out.println(next.toString());
        }
    }
}
